/*
 * Copyright (c) 2025, 廖树财, <study_2030@163.com>
 *
 * PES1.0.3-YCYW is licensed under Mulan PSL v2.
 * You can use this software according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of Mulan PSL v2 at:
 *         http://license.coscl.org.cn/MulanPSL2     
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PSL v2 for more details.
 */
#ifndef _IOTA_H_
#define _IOTA_H_

#include "define.h"
#include "stdarg.h"

#if defined(_WINDOWS) || defined(WIN32)
#ifdef IOTA_EXPORTS
#define IOTA_API extern "C" __declspec(dllexport)
#else
#define IOTA_API extern "C" __declspec(dllimport)
#endif
#else
#define IOTA_API
#endif
typedef void (*PFN_CALLBACK_HANDLER)(void *context, int messageId, int code, char *message);
typedef void (*PFN_CALLBACK_HANDLER_TOPIC)(void *context, int messageId, int code, const char *topic, char *message);
typedef void (*PFN_LOG_CALLBACK_HANDLER)(int level, char *format, va_list args);
typedef void (*PFN_EXTERNAL_CALLBACK_HANDLER)(void *context, void *param);
typedef void (*PFN_CALLBACK_HANDLER_SAG)(char *top, char *data, int size);
void IOTA_SetCallBackSurAg(PFN_CALLBACK_HANDLER_SAG pfnCallbackHandler);
int IOTA_SendMqtt(char *pcTopicName, char *data, int size);
///
IOTA_API int IOTA_Init(char *pcWorkPath, char *pcLogPath);
IOTA_API void IOTA_Destroy();

IOTA_API void IOTA_SetCallback(int iItem, PFN_CALLBACK_HANDLER pfnCallbackHandler);

IOTA_API void IOTA_SetCallbackWithTopic(PFN_CALLBACK_HANDLER_TOPIC pfnCallbackTopicHandler);
IOTA_API void IOTA_SetPrintLogCallback(PFN_LOG_CALLBACK_HANDLER pfnLogCallbackHandler);

IOTA_API int IOTA_ConfigSetStr(int iItem, char *pValue);
IOTA_API int IOTA_ConfigSetUint(int iItem, HW_UINT uiValue);

IOTA_API int IOTA_Login();
IOTA_API int IOTA_Logout();

IOTA_API int IOTA_HubDeviceAdd(HW_UINT uiMid, ST_IOTA_DEVICE_INFO *pstInfo);
IOTA_API int IOTA_HubDeviceRemove(HW_UINT uiMid, char *pcDeviceId);
IOTA_API int IOTA_DeviceStatusUpdate(HW_UINT uiMid, char *pcDeviceId, char *pcStatus);
IOTA_API int IOTA_HubDeviceQuery(HW_UINT uiMid, char *pcMarker, HW_UINT uiLimit, ST_IOTA_DEVICE_INFO *pstDeviceInfo);

IOTA_API int IOTA_ServiceDataReport(char *pcDeviceId, char *pcServiceId, char *pcServiceProperties);
IOTA_API int IOTA_ServiceCommandResponse(HW_UINT uiMid, HW_UINT uiResultCode, char *pcCommandResponse);

IOTA_API int IOTA_ServiceCustomTopicReport(ST_IOTA_BatchReportProperties *pstDevInfo, char *pcTopicVersion, char *pcCustomTopic);
IOTA_API int IOTA_SubscribeCustomTopic(char *pcTopicVersion, char *pcCustomTopic);

IOTA_API int IOTA_SetCertPath(char *pcCertPath);

#endif // _IOTA_H_
